<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/style.css"></link>
</head>
<body>
<div class="login-form-wrap">
    <h1>黑马程序员</h1>
    <form class="login-form" action="#" id="regist" method="get" autocomplete="off">
        <label>
            <input type="text" id="username" name="username" placeholder="Username..." value="">
        </label>
        <label>
            <input type="password" id="password" name="password" placeholder="Password..." value="">
        </label>
        <input type="submit" value="注册">
    </form>
</div>
</body>
<script>
    function name() {
        let a=document.getElementById("username").value;
        let reg1=/^[a-zA-Z]{4,16}$/;
        if (!reg1.test(a)){
            alert("用户名错误，请输入4到16位纯字母")
            return false;
        }
        return true;
    }
    document.getElementById("regist").onsubmit=function () {
        return name;
    }
</script>
</html>